fin = open('nuevos_genomas')

genomas = fin.read().strip().split('\n')
fin.close()

from Bio import SeqIO
codon = {}
gen_codon = {}
for genoma in genomas:
    genoma = genoma +'.fasta'
    data = list(SeqIO.parse(open('/home/rafa/Genomas_bact_archaea/seleccionados/'+genoma), 'fasta'))
    for d in data:
        for i in range(0, len(d.seq) - 2):
            try:
               codon[str(d.seq[i:i+3])]+=1
            except:
               codon[str(d.seq[i:i+3])]=1
        print genoma +'\t'+ '\t'.join([str(c) for c in codon.keys()])
        print genoma +'\t'+ '\t'.join([str(c/float(len(d.seq))) for c in codon.values()])

#print 'Genoma\t'+'\t'.join(gen_codon[genomas[0]].keys())

